package com.piano.moguyun.utils;

import android.database.Cursor;
import android.text.TextUtils;
import android.util.Log;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;

public class IOUtil {
//    private IOUtil() {
//    }
//
//    public static void closeQuietly(Closeable closeable) {
//        if (closeable != null) {
//            try {
//                closeable.close();
//            } catch (Closeable closeable2) {
//            }
//        }
//    }
//
//    public static void closeQuietly(Cursor cursor) {
//        if (cursor != null) {
//            try {
//                cursor.close();
//            } catch (Cursor cursor2) {
//            }
//        }
//    }
//
//    public static byte[] readBytes(InputStream inputStream) throws IOException {
//        Closeable byteArrayOutputStream;
//        if (!(inputStream instanceof BufferedInputStream)) {
//            inputStream = new BufferedInputStream(inputStream);
//        }
//        try {
//            byteArrayOutputStream = new ByteArrayOutputStream();
//            try {
//                byte[] bArr = new byte[1024];
//                while (true) {
//                    int read = inputStream.read(bArr);
//                    if (read != -1) {
//                        byteArrayOutputStream.write(bArr, 0, read);
//                    } else {
//                        inputStream = byteArrayOutputStream.toByteArray();
//                        closeQuietly(byteArrayOutputStream);
//                        return inputStream;
//                    }
//                }
//            } catch (Throwable th) {
//                inputStream = th;
//                closeQuietly(byteArrayOutputStream);
//                throw inputStream;
//            }
//        } catch (Throwable th2) {
//            inputStream = th2;
//            byteArrayOutputStream = null;
//            closeQuietly(byteArrayOutputStream);
//            throw inputStream;
//        }
//    }
//
//    public static byte[] readBytes(InputStream inputStream, long j, int i) throws IOException {
//        if (j > 0) {
//            while (j > 0) {
//                long skip = inputStream.skip(j);
//                if (skip <= 0) {
//                    break;
//                }
//                j -= skip;
//            }
//        }
//        j = new byte[i];
//        for (int i2 = 0; i2 < i; i2++) {
//            j[i2] = (byte) inputStream.read();
//        }
//        return j;
//    }
//
//    public static String readStr(InputStream inputStream) throws IOException {
//        return readStr(inputStream, "UTF-8");
//    }
//
//    public static String readStr(InputStream inputStream, String str) throws IOException {
//        if (TextUtils.isEmpty(str)) {
//            str = "UTF-8";
//        }
//        if (!(inputStream instanceof BufferedInputStream)) {
//            inputStream = new BufferedInputStream(inputStream);
//        }
//        Reader inputStreamReader = new InputStreamReader(inputStream, str);
//        inputStream = new StringBuilder();
//        str = new char[1024];
//        while (true) {
//            int read = inputStreamReader.read(str);
//            if (read < 0) {
//                return inputStream.toString();
//            }
//            inputStream.append(str, 0, read);
//        }
//    }
//
//    public static void writeStr(OutputStream outputStream, String str) throws IOException {
//        writeStr(outputStream, str, "UTF-8");
//    }
//
//    public static void writeStr(OutputStream outputStream, String str, String str2) throws IOException {
//        if (TextUtils.isEmpty(str2)) {
//            str2 = "UTF-8";
//        }
//        Writer outputStreamWriter = new OutputStreamWriter(outputStream, str2);
//        outputStreamWriter.write(str);
//        outputStreamWriter.flush();
//    }
//
//    public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
//        if (!(inputStream instanceof BufferedInputStream)) {
//            inputStream = new BufferedInputStream(inputStream);
//        }
//        if (!(outputStream instanceof BufferedOutputStream)) {
//            outputStream = new BufferedOutputStream(outputStream);
//        }
//        byte[] bArr = new byte[1024];
//        while (true) {
//            int read = inputStream.read(bArr);
//            if (read != -1) {
//                outputStream.write(bArr, 0, read);
//            } else {
//                outputStream.flush();
//                return;
//            }
//        }
//    }
//
//    public static boolean deleteFileOrDir(File file) {
//        return FileUtil.deleteFileOrDir(file);
//    }
}
